﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PowerHub.MES.Common.Utility;
using PowerHub.MES.DTO.BasicData.DTO;
using PowerHub.MES.DTO.BasicData.QueryDto;
using PowerHub.MES.Entities.BasicData;
using PowerHub.MES.IServices.IBasic;
using PowerHub.MES.ReturnEntity;

namespace PowerHub.MES.Controllers.Basic
{

    /// <summary>
    /// 部门
    /// </summary>
    [ApiController]
    [Route("Api/MES/Basic/[controller]/[action]")]
    public class DepartmentController
    {

        private IBasicData_DepartmentServices _DepartmentServices;

        public DepartmentController(IBasicData_DepartmentServices DepartmentServices)
        {
            _DepartmentServices = DepartmentServices;
        }

        /// <summary>
        /// 获取部门列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("获取部门列表")]
        public async Task<OperationPageResult<List<BasicData_Department>>> GetBasicData_DepartmentPageListAsync([FromBody] QueryBasicData_DepartmentDTO pageQuery)
        {
            return await _DepartmentServices.GetBasicData_DepartmentPageListAsync(pageQuery);
        }


        /// <summary>
        /// 批量删除部门
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("批量删除部门")]
        public async Task<OperationResult<object>> BatchDeletionBasicData_DepartmentAsync([FromBody] List<string>  Query)
        {
            return await _DepartmentServices.BatchDeletionBasicData_DepartmentAsync(Query);
        }

        /// <summary>
        /// 更新部门
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("更新部门")]
        public async Task<OperationResult<object>> UpdateBasicData_DepartmentAsync([FromBody] BasicData_DepartmentDTO Query)
        {
            return await _DepartmentServices.UpdateBasicData_DepartmentAsync(Query);
        }

        /// <summary>
        /// 添加部门
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("添加部门")]
        public async Task<OperationResult<object>> CreateBasicData_DepartmentAsync([FromBody] BasicData_DepartmentDTO Query)
        {
            return await _DepartmentServices.CreateBasicData_DepartmentAsync(Query);
        }
    }
}
